package com.xnyzc.lhy.order.controller.sys.vehicle;


import com.xnyzc.lhy.common.entity.Rv;
import com.xnyzc.lhy.common.util.TokenUtil;
import com.xnyzc.lhy.order.entity.param.order.EndReceiptParam;
import com.xnyzc.lhy.order.entity.param.order.StartReceiptParam;
import com.xnyzc.lhy.order.service.system.IOaSysVehicleService;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 车辆信息表 前端控制器
 * </p>
 *
 * @author huxuekuo
 * @since 2019-07-24
 */
@RestController
@RequestMapping("/sys/vehicle/oaSysVehicle")
public class OaSysVehicleController {

    @Autowired
    private IOaSysVehicleService vehicleService;

    @ApiOperation(value = "获取车辆列表", notes = "获取车辆列表")
    @GetMapping("/listVehicle")
    public Rv listVehicle(
            @ApiParam(name = "company_id", value = "机构或公司ID") Long company_id,
            @ApiParam(name = "type", value = "类型") Integer type,
            @ApiParam(name = "vehNo", value = "车牌号") String vehNo
    ) {
        return vehicleService.listVehicle(company_id, type, vehNo);
    }

    @PostMapping("/startReceipt")
    @ApiOperation(value = "开始接单", notes = "开始接单")
    public Rv startReceipt(
            @ApiParam(name = "param", value = "开始接单接参类") @RequestBody StartReceiptParam param
    ) {
        return vehicleService.startReceipt(param);
    }

    @PostMapping("/endReceipt")
    @ApiOperation(value = "停止接单", notes = "停止接单")
    public Rv endReceipt(
            @ApiParam(name = "param", value = "停止接单参数") @RequestBody EndReceiptParam param
    ) {
        return vehicleService.endReceipt(param);
    }

    @GetMapping("/bindVehicle")
    @ApiOperation(value = "绑定车辆", notes = "绑定车辆")
    public Rv bindVehicle(
            @ApiParam(name = "vehicleId", value = "车辆ID") Long vehicleId
    ) {
        long tokenUserId = TokenUtil.getTokenUserId();
        return vehicleService.bindVehicle(tokenUserId, vehicleId);
    }

}
